package org.business.accounting.service;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.business.accounting.interfaces.Computer;

public class ComputerDAOImpl implements ComputerDAO {
	
	private Map<String, Computer> compMap;
	
	public ComputerDAOImpl() {
		compMap = new HashMap<String, Computer>();
	}
	
	public Collection<Computer> retrieve() {
		return compMap.values();
	}
	
	public Computer save(Computer computer) {
		return compMap.put(computer.getName(), computer);
	}
	
	public Computer remove(String key) {
		return compMap.remove(key);
	}
	
	public void clear(boolean b) {
		if (b) {
			compMap.clear();
		}
	}
	
	public void addAll(Map<String, Computer> map) {
		compMap.putAll(map);
	}
	
	public Computer get(String key) {
		return compMap.get(key);
	}
}
